package com.lxb.myforum.repository

import org.springframework.data.jpa.repository.JpaSpecificationExecutor
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.PagingAndSortingRepository
import org.springframework.stereotype.Repository

import com.lxb.myforum.pojo.Star
import com.lxb.myforum.pojo.StarType
import com.lxb.myforum.pojo.User

/**
 *
 * @author lxb
 */
@Repository
interface StarRepository : PagingAndSortingRepository<Star, Long>, JpaSpecificationExecutor<Star> {
    fun findOneByTargetIdAndTypeAndUser(targetId: Long, type: StarType, u: User): Star

    @Query("select s from Star s where s.type = ?1 and s.user = ?2 and s.targetId in ?3")
    fun checkStar(type: StarType, u: User, targetIds: List<Long>): List<Star>
}
